IAM Roles For ECS
To set up the ECS we will require 4 types of roles. If you go to IAM -> Roles -> Create Role -> Elastic Container Service, you will notice the 4 roles use case. We will have to go through each of them and create these roles.
- Role For EC2: Will be attached with to the
EC2instance. This will allow theECS Agentto communicate with theECSandECR. Create a role namedecsInstanceRolefromEC2 Role for Elastic Container Service.
Allows EC2 instances in an ECS cluster to access ECS.
- Role for
ECS: Will be attached to theECS. This will allowECSto manage resources on our behalf. Create a role namedecsRolefromElastic Container Service.
Allows ECS to create and manage AWS resources on your behalf.
- Role for
ECS Task: Will be attached to theECS Task. This will allow execute the task. Create a role namedecsAutoscalingRolefrom theElastic Container Service Autoscale.
Allows Auto Scaling to access and update ECS services.
- Role for
Auto Scaling: Only if we use EC2 instance to run docker this role will be required. ForFargatewe will not require any of these. Create a role namedecsTaskExecutionRolewith onlyAmazonECSTaskExecutionRolePolicypolicy fromElastic Container Service Task.
Allows ECS tasks to call AWS services on your behalf.